package com.rw.tool.util.expression.expression.parser.element;

import com.rw.tool.util.expression.element.ExpressionElement;
import com.rw.tool.util.string.StringScanner;

import java.util.Optional;

public abstract class ElementParser<T> {
    private final Class<T> targetState;

    public ElementParser(Class<T> targetState) {
        this.targetState = targetState;
    }

    public boolean trigger(Class<? extends ExpressionElement> element) {
        return element.isAssignableFrom(targetState);
    }

    public abstract Optional<ExpressionElement> handler(StringScanner scanner, int scale);
}
